home *** CD-ROM | disk | FTP | other *** search
/ F1 Licenseware / F1 Licenseware - Volume 1.iso / disks / 049a.dms / 049a.adf / SOURCE_CODE / AJC-POLY.AMOS / AJC-POLY.amosSourceCode
AMOS Source Code  |  1993-09-09  |  2KB  |  86 lines

  1. '
  2. '  "Poly" By Andrew Campbell 
  3. '
  4. '  Enter a value (eg: 7) then drag the mouse to the <---- LEFT 
  5. '  whilst holding the LEFT BUTTON to make a linked 
  6. '  polygon. The RIGHT button will return to the input. 
  7. '  
  8. '  This program was written to help my brother who took
  9. '  GCSE Maths. Perhaps it might assist someone else...?
  10. '
  11. '  Try a value of 20 and make a BIG polygon! 
  12. '
  13. Dim XPOINTS(150),YPOINTS(150)
  14. Global R,NP,FINISHED,TMS
  15.  
  16. Screen Open 0,320,256,16,Lowres
  17. Curs Off : Flash Off : Paper 0 : Cls 0
  18. Ink 2,6
  19.  
  20. HEAVEN:
  21. Cls 0
  22. ANG=0 : Input "Enter number of sides... ";NP
  23. Cls 0
  24.  
  25. Global XPOINTS(),YPOINTS()
  26.  
  27. _LOOP:
  28.  
  29. Repeat 
  30.  X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
  31.  If Mouse Key=2 : Goto HEAVEN : End If 
  32. Until Mouse Key=1
  33.  
  34. While Mouse Key=1
  35.      X2=X Screen(X Mouse) : Y2=Y Screen(Y Mouse)
  36.      Gr Writing 2
  37.      R=(X-X2)/2
  38.      If R<1 : R=1 : End If 
  39.      _POLYGON[X,Y,NP,R,R,ANG,1]
  40.      _POLYGON[X,Y,NP,R,R,ANG,1]
  41. Wend 
  42.  
  43.  Gr Writing 0
  44.  FINISHED=1
  45.  _POLYGON[X,Y,NP,R,R,ANG,1]
  46.  
  47.  For J=1 To NP
  48.   For I=1 To NP
  49.    Draw XPOINTS(J),YPOINTS(J) To XPOINTS(I),YPOINTS(I)
  50.   Next I
  51.  Next J
  52.  
  53. Goto _LOOP
  54.  
  55. Procedure _POLYGON[_XCOOR,_YCOOR,_POINTS,_XSIZE,_YSIZE,_ANGLE,_FILLED]
  56.  
  57.    Degree 
  58.    If _POINTS<3
  59.       _POINTS=3
  60.    End If 
  61.    If _POINTS>360
  62.       _POINTS=360
  63.    End If 
  64.  
  65.    TMS=0
  66.  
  67.    For N=0+_ANGLE To 359+_ANGLE Step 360/_POINTS
  68.  
  69.       Inc TMS
  70.  
  71.       X1=_XCOOR+Cos(N)*R
  72.       Y1=_YCOOR+Sin(N)*R
  73.  
  74.       X2=_XCOOR+Cos(N+360/_POINTS)*R
  75.       Y2=_YCOOR+Sin(N+360/_POINTS)*R
  76.  
  77.      If FINISHED=1
  78.       XPOINTS(TMS)=X2
  79.       YPOINTS(TMS)=Y2
  80.      End If 
  81.  
  82.       Polyline X1,Y1 To X2,Y2
  83.  
  84.    Next N
  85.  
  86. End Proc